const path = require('path')
const webpack = require('webpack')
const { merge } = require('webpack-merge')
const commonConfig = require('./webpack.common')

module.exports = merge(commonConfig, {
  mode: 'development',
  devtool: 'cheap-module-eval-source-map',
  devServer: {
    open: false,
    hot: true,
    port: 6800,
    clientLogLevel: 'warning'
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [
          'vue-style-loader',
          {
            loader: 'css-loader',
            options: {
              esModule: false
            }
          },
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                config: path.join(__dirname, '../postcss.config.js')
              }
            }
          }
        ]
      },
      {
        test: /\.less$/,
        use: [
          'vue-style-loader',
          {
            loader: 'css-loader',
            options: {
              esModule: false
            }
          },
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                config: path.join(__dirname, '../postcss.config.js')
              }
            }
          },
          'less-loader'
        ]
      },
      {
        test: /\.vue$/,
        enforce: 'pre',
        exclude: [
          path.resolve('./node_modules')
        ],
        loader: 'eslint-loader'
      },
      {
        test: /\.js$/,
        enforce: 'pre',
        exclude: [
          path.resolve('./node_modules')
        ],
        loader: 'eslint-loader'
      }
    ]
  },
  plugins: [
    new webpack.HotModuleReplacementPlugin()
  ]
})
